package com.ruoyi.employer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.employer.domain.CargoWrap;
import com.ruoyi.employer.service.ICargoWrapService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 包装方式信息Controller
 * 
 * @author adf
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/employer/wrap")
public class CargoWrapController extends BaseController
{
    @Autowired
    private ICargoWrapService cargoWrapService;

    /**
     * 查询包装方式信息列表
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:list')")
    @GetMapping("/list")
    public TableDataInfo list(CargoWrap cargoWrap)
    {
        startPage();
        List<CargoWrap> list = cargoWrapService.selectCargoWrapList(cargoWrap);
        return getDataTable(list);
    }

    /**
     * 查询所有包装方式信息列表
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:list')")
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<CargoWrap> list = cargoWrapService.selectCargoWrapList(null);
        return getDataTable(list);
    }

    /**
     * 导出包装方式信息列表
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:export')")
    @Log(title = "包装方式信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CargoWrap cargoWrap)
    {
        List<CargoWrap> list = cargoWrapService.selectCargoWrapList(cargoWrap);
        ExcelUtil<CargoWrap> util = new ExcelUtil<CargoWrap>(CargoWrap.class);
        util.exportExcel(response, list, "包装方式信息数据");
    }

    /**
     * 获取包装方式信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cargoWrapService.selectCargoWrapById(id));
    }

    /**
     * 新增包装方式信息
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:add')")
    @Log(title = "包装方式信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CargoWrap cargoWrap)
    {
        return toAjax(cargoWrapService.insertCargoWrap(cargoWrap));
    }

    /**
     * 修改包装方式信息
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:edit')")
    @Log(title = "包装方式信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CargoWrap cargoWrap)
    {
        return toAjax(cargoWrapService.updateCargoWrap(cargoWrap));
    }

    /**
     * 删除包装方式信息
     */
    @PreAuthorize("@ss.hasPermi('employer:wrap:remove')")
    @Log(title = "包装方式信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cargoWrapService.deleteCargoWrapByIds(ids));
    }
}
